import request from 'umi-request';

// 获取教师课程
export const getTeacherCourse = async (data: any) => {
    return request<any>('/course/teacher', {
        method: 'GET',
        params: { teacherId: data },
    });
};

// 根据课程获取老师测验
export const getTeacherTest = async (data: any) => {
    return request<any>('/test/teacher', {
        method: 'GET',
        params: { courseId: data },
    });
};

// 根据课程获取学生列表
export const getStudentList = async (data: any) => {
    return request<any>('/students/course', {
        method: 'GET',
        params: { courseId: data },
    });
};

// 删除学生
export const deleteStudent = async (data: any) => {
    return request<any>('/course/students/delete', {
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 根据年级获取学生
export const getYearStudent = async (data: any) => {
    return request<any>('/students', {
        method: 'GET',
        params: { year: data }
    });
};

// 根据年级添加学生
export const addYearStudent = async (data: any) => {
    return request<any>('/course/students/add', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 修改课程
export const changeCourse = async (data: any) => {
    return request<any>('/course/update', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 新建课程
export const addCourse = async (data: any) => {
    return request<any>('/course/add', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 删除课程
export const deleteCourse = async (data: any) => {
    return request<any>('/course/delete', {
        method: 'GET',
        params: { courseId: data }
    });
};

// 删除测验
export const deleteTests = async (data: any) => {
    return request<any>('/test/delete', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 获取带答案的测验
export const getAnswerTest = async (data: any) => {
    return request<any>('/questions/test/answer', {
        method: 'GET',
        params: { testId: data }
    });
};

// 获取测验分数
export const getTestResult = async (data: any) => {
    return request<any>('/score/test', {
        method: 'GET',
        params: { testId: data }
    });
};

// 添加测验
export const addTests = async (data: any) => {
    return request<any>('/test/add', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 为测验添加问题
export const addTestQuestions = async (data: any) => {
    return request<any>('/test/questions/add', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};